package com.lh.service.impl;

import com.github.pagehelper.PageInfo;
import com.lh.domain.Info;
import com.lh.domain.vo.InfoQuery;
import com.lh.mapper.InfoMapper;
import com.lh.service.InfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lh.utils.APKCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lh
 * @since 2023-10-24
 */
@Service
public class InfoServiceImpl extends ServiceImpl<InfoMapper, Info> implements InfoService {

    @Autowired
    private InfoMapper infoMapper;

    @Autowired
    private APKCode apkCode;


    @Override
    public List<InfoQuery> selectAllInfo(InfoQuery i) {return infoMapper.selectAllInfo(i);
    }

    @Override
    public APKCode selectAPKName(String name) {
        int i = infoMapper.selectAPKNameInt(name);
        if(name == null || name.trim().isEmpty()){
            apkCode.setAPKName("empty");
        }else if(i > 0){
            apkCode.setAPKName("exist");
        }else{
            apkCode.setAPKName("noexist");
        }
        return apkCode;
    }

    @Override
    public int addInfo(Info info) {
        int insert = infoMapper.insert(info);
        return insert;
    }

    @Override
    public Info selectById(Integer id) {
        return infoMapper.selectById(id);
    }

    @Override
    public InfoQuery selectByIdM(Integer devId, Integer id) {
        return infoMapper.selectByIdM(devId,id);
    }


}
